<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>The Yaf_Bootstrap_Abstract class</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="yaf-application.wakeup.html">Yaf_Application::__wakeup</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="class.yaf-dispatcher.html">Yaf_Dispatcher</a></div>
 <div class="up"><a href="book.yaf.html">Yaf</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="class.yaf-bootstrap-abstract" class="reference">

 <h1 class="title">The Yaf_Bootstrap_Abstract class</h1>
 

 <div class="partintro"><p class="verinfo">(No version information available, might only be in Git)</p>


  <div class="section" id="yaf-bootstrap-abstract.intro">
   <h2 class="title">简介</h2>
   <p class="para">
     Bootstrap是用来在Application运行(run)之前做一些初始化工作的机制.
   </p>
   <p class="para">
    你可以通过继承<strong class="classname">Yaf_Bootstrap_Abstract</strong>
    来定义自己的Bootstrap类.
   </p>
   <p class="para">
    在Bootstrap类中所有以&quot;_init&quot;开头的公有的方法,
    都会被按照定义顺序依次在<span class="methodname"><a href="yaf-application.bootstrap.html" class="methodname">Yaf_Application::bootstrap()</a></span>
    被调用的时刻调用.
   </p>
  </div>


 <div class="section">
  <h2 class="title">范例</h2>
  <div class="example" id="example-4030">
   <p><strong>Example #1 Bootstrap example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">/*&nbsp;bootstrap&nbsp;class&nbsp;should&nbsp;be&nbsp;defined&nbsp;under&nbsp;./application/Bootstrap.php&nbsp;*/<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">Bootstrap&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #0000BB">Yaf_Bootstrap_Abstract&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;</span><span style="color: #0000BB">_initConfig</span><span style="color: #007700">(</span><span style="color: #0000BB">Yaf_Dispatcher&nbsp;$dispatcher</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">__METHOD__</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;</span><span style="color: #0000BB">_initPlugin</span><span style="color: #007700">(</span><span style="color: #0000BB">Yaf_Dispatcher&nbsp;$dispatcher</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">__METHOD__</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$config&nbsp;</span><span style="color: #007700">=&nbsp;array(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"application"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;array(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"directory"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">dirname</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"/application/"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />&nbsp;&nbsp;&nbsp;);<br />&nbsp;<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$app&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">Yaf_Application</span><span style="color: #007700">(</span><span style="color: #0000BB">$config</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$app</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">bootstrap</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>以上例程的输出类似于：</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
string(22) &quot;Bootstrap::_initConfig&quot;
string(22) &quot;Bootstrap::_initPlugin&quot;
</pre></div>
   </div>
  </div>
 </div>

  <div class="section" id="yaf-bootstrap-abstract.synopsis">
   <h2 class="title">类摘要</h2>


   <div class="classsynopsis">
    <div class="ooclass"></div>


    <div class="classsynopsisinfo">
     <span class="ooclass">
      <span class="modifier">abstract</span>
      <strong class="classname">Yaf_Bootstrap_Abstract</strong>
     </span>
     {</div>
    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 属性 */</div>
    
    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 方法 */</div>
   }</div>


  </div>

 </div>

</div>
<hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="yaf-application.wakeup.html">Yaf_Application::__wakeup</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="class.yaf-dispatcher.html">Yaf_Dispatcher</a></div>
 <div class="up"><a href="book.yaf.html">Yaf</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
